import Vue from 'vue'
import {fetch, put, post, del} from "./baseApi";

Vue.prototype.$fetch = fetch
Vue.prototype.$put = put
Vue.prototype.$post = post
Vue.prototype.$delete = del
export const getUsersList = (params) => {
  return Vue.prototype.$fetch("users", params)
}

export const updateUserState = (url) => {
  return Vue.prototype.$put(url)
}

export const addUser = (data) => {
  return Vue.prototype.$post("users", data)
}

export const getUserById = (id) => {
  return Vue.prototype.$fetch("users/" + id)
}

export const editUserInfo = (payload) => {
  return Vue.prototype.$put("users/" + payload.id, payload.user)
}

export const deleteUserById = (id) => {
  return Vue.prototype.$delete("users/" + id)
}


export const saveRoleInfo = (payload) => {
  return Vue.prototype.$put("users/" + payload.id + "/role", payload.rid)
}

